// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   TrainerProfileDAO.java

package com.nervytech.tutorcruise.db.dao.mysql.impl;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;
import java.util.List;

import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.support.JdbcDaoSupport;
import org.springframework.stereotype.Repository;

import com.nervytech.tutorcruise.db.dao.interfaces.ITrainerProfileDAO;
import com.nervytech.tutorcruise.db.dao.model.CompanyProfile;
import com.nervytech.tutorcruise.db.dao.model.TrainerProfile;

@Repository("trainerProfileDAO")
public class TrainerProfileDAO extends JdbcDaoSupport implements
		ITrainerProfileDAO {

	@Autowired
	TrainerProfileDAO(DataSource dataSource) {
		setDataSource(dataSource);
	}

	public void saveTrainerProfile(TrainerProfile trainerprofile) {
	}

	public List<TrainerProfile> getTrainerProfile(long userId) {
		RowMapper<TrainerProfile> mapper = new RowMapper<TrainerProfile>() {

			public TrainerProfile mapRow(ResultSet rs, int rowNum)
					throws SQLException {
				TrainerProfile trainerProfile = new TrainerProfile();
				trainerProfile.setAchievementSummary(rs
						.getString("achievement_summary"));
				trainerProfile.setBlogs(rs.getString("blogs"));
				trainerProfile.setCertification(rs.getString("certifications"));
				trainerProfile.setEduSummary(rs.getString("edu_summary"));
				trainerProfile.setFacebookUrl(rs.getString("facebook_url"));
				trainerProfile.setGoogleplusUrl(rs.getString("googleplus_url"));
				trainerProfile.setIsPortalCertified(rs
						.getShort("is_portal_certified"));
				trainerProfile.setIsTechCertified(rs
						.getShort("is_tech_certified"));
				trainerProfile.setLinkedinUrl(rs.getString("linkedin_url"));
				trainerProfile.setProfessionalSummary(rs
						.getString("prof_summary"));
				trainerProfile.setProfExperience(rs.getInt("prof_exp"));
				trainerProfile.setRating(rs.getInt("rating"));
				trainerProfile.setSkillSummary(rs.getString("skill_summary"));
				trainerProfile.setSpecialises(rs.getString("specialises"));
				trainerProfile.setTaggedSkills(rs.getString("tagged_skills"));
				trainerProfile.setTeachingExperience(rs.getInt("teaching_exp"));
				trainerProfile.setTechingSummary(rs
						.getString("teaching_summary"));
				trainerProfile.setTwitterUrl(rs.getString("twitter_url"));
				System.out.println("SO FARRRRRRRRRRRRRRRRRRRRRRRRRRRRRR");
				trainerProfile.setFullName(rs.getString("full_name"));
				trainerProfile.setUserType(rs.getInt("user_type"));
				trainerProfile.setUserStatus(rs.getInt("user_status"));
				trainerProfile.setCategory(rs.getInt("category"));
				trainerProfile.setCity(rs.getInt("city"));
				trainerProfile.setZipCode(rs.getString("zip_code"));
				trainerProfile.setImageUrl(rs.getString("image_url"));
				trainerProfile.setContactNumber(rs.getString("contact_number"));
				System.out.println("RETURNING PROFILEEEEEEEEEEEEEEEE ");
				return trainerProfile;
			}

		};
		String selectUserQuery = (new StringBuilder(
				"SELECT u.full_name,u.user_type,u.user_status,u.city,u.category,u.zip_code, u.image_url,u.contact_number,u.mobile_verified,tp.specialises,tp.tagged_skills,tp.certifications, tp.rating,tp.is_portal_certified,tp.is_tech_certified,tp.prof_exp,tp.teaching_exp,tp.teaching_summary, tp.prof_summary,tp.skill_summary,tp.edu_summary,tp.achievement_summary,tp.linkedin_url,tp.facebook_url, tp.twitter_url,tp.googleplus_url,tp.blogs FROM TRAINER_PROFILE tp ,USER u WHERE u.user_id="))
				.append(userId).append(" and tp.user_id=u.user_id").toString();
		logger.debug((new StringBuilder("Select user Query : ")).append(
				selectUserQuery).toString());
		return getJdbcTemplate().query(selectUserQuery, mapper);
	}

	public void updateTrainerProfile(CompanyProfile companyprofile) {
	}

	public void addNewTrainer(long userId, Date createdTime, Date updatedTime) {
		String saveUserQuery = "insert into trainer_profile(user_id,created_time,updated_time) values(?,?,?)";
		Object parms[] = { Long.valueOf(userId), createdTime, updatedTime };
		getJdbcTemplate().update(saveUserQuery, parms);
	}
}
